#ifndef PACKAGE_SURPPORT_H
#define PACKAGE_SURPPORT_H

#include "clonable_package.h"
#include "pool_surpport.h"
#include "serial_surpport.h"
#include "package_mgr.h"
#include "do_job_on_initilizing_object.h"

#define RegisterPackage(name, id)  \
	DoJobOnInitializing(name, \
	boost::bind(&PackageMgr::add, PackageMgr::getInstace(), boost::shared_ptr<IPackage>(new name()))); \
	const size_t name::messageID_ = id; \
	PoolSurpportImp(name)


#define SurpportSerializing(argList) \
public:\
	virtual void poll(istream& is) \
	{ \
	serial(is); \
	} \
	\
	virtual void push(ostream& os) \
	{ \
	serial(os); \
	} \
	virtual size_t size() const \
	{ \
	return (serial::SizeCaculator() & argList).size(); \
	} \
private: \
template<typename Stream> \
	void serial(Stream& stream) \
	{ \
	using namespace serial; \
	stream & argList; \
	} \
public:

#define SurpportPktSerializing(argList) \
	SurpportSerializing(argList) \
	virtual size_t messageID() const \
	{ \
	return messageID_; \
	} \
public: \
	static const size_t messageID_; \



#define Package(name) class name : public PoolSurpport<name>, public ClonablePackage<name>


#endif
